package com.tac.xiangmu3.common;


import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.sql.SQLIntegrityConstraintViolationException;
@RestControllerAdvice(annotations = {RestController.class})
@ResponseBody
public class GlobalException {

    @ExceptionHandler(SQLIntegrityConstraintViolationException.class)
    public R<String> ycException(SQLIntegrityConstraintViolationException ex){
        return R.error("服务器异常");
    }
    @ExceptionHandler(CostomException.class)
    public R<String> ycException(CostomException ex){
        return R.error(ex.getMessage());
    }
}
